# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.contrib import admin
from django import forms
from appBlog.models import *

# Register your models here.

def hello(self, request, queryset):
	print 'hello'
	self.message_user(request, '操作成功')

admin.site.add_action(hello,'hello')

@admin.register(Poem)
class PoemAdmin(admin.ModelAdmin):
	list_display = ('title', 'author', 'content')
	fields = ['title', 'author', 'content']
	widgets = {
		'content':forms.Textarea(attrs={'cols':'20','rows':'30'})
	}

	def foo(self, request, queryset):
		for qs in queryset:
			qs.content =  '这只是一个测试'
			qs.save()
		self.message_user(request,'操作成功')
	actions = [foo]
	foo.short_description = 'bbb'

	def get_action(self, request):
		actions = super(PoemAdmin,self).get_action(request)
		print actions
		if 'hello' in actions:
			del actions['hello']
		return actions


@admin.register(ToDo)
class ToDoAdmin(admin.ModelAdmin):
	list_display = ('content','is_done','priority')


# admin.site.disable_action('delete_selected')